﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="UserRightAssign.aspx.cs" Inherits="ZLCMS.Web.SystemManage.Basics.RightConfig.UserRight.UserRightAssign" %>

<%=_framePage.GetPagerFormHtml(Request.RawUrl)%>

<form id="pageForm" method="post" runat="Server" class="pageForm">
<div class="pageContent">
	
	<div class="unitBox" style="float:left; display:block; overflow:auto; width:200px;">
	

<div class="pageHeader" style="border:1px #B8D0D6 solid">
	<div class="searchBar">
		<table class="searchContent">
			<tr>
				<td>
				    系统用户
				</td>
			</tr>
		</table>
    </div>
</div>

<div class="pageContent" style="border-left:1px #B8D0D6 solid;border-right:1px #B8D0D6 solid">


    <ul class="tree" layoutH="65">
        <asp:repeater runat="server" id="roles">
            <ItemTemplate>
                <li>
                <a href='<%=Request.Path %>?user=<%#Eval("UserAccount")%>' target="navTab" rel="<%= _framePage.NavTabId %>" title="<%= _framePage.NavTabTitle %>" onclick="ZLAN_DWZ_EX.redirect(this);" >
                <span <%#(string)Eval("UserAccount") == CurrentUser? "style='color:red'":"" %>>
                <%#Eval("UserName")%>(<%#Eval("UserAccount")%>)</span>
                </a></li>            
            </ItemTemplate>
        </asp:repeater>
    </ul>	
	<div class="panelBar">
	</div>
</div>


</div>
	
	<div class="unitBox" style="margin:0px 0px 0px 200px ">
<div class="pageHeader" style="border:1px #B8D0D6 solid">
	<div class="searchBar">
		<table class="searchContent">
			<tr>
				<td>
					权限分组：
				</td>
				<td style="width:150px"><asp:dropdownlist runat="server" class="combox" id="group" cond="group"></asp:dropdownlist></td>
				<td>
				
			    <a class="buttonActive" href="<%= Request.Path %>?role=<%=CurrentUser %>" onclick="ZLAN_DWZ_EX.redirect(this);" 
			    target="navTab" rel="<%= _framePage.NavTabId %>" title="角色权限分配"><span>&nbsp;查&nbsp;询&nbsp;</span></a>
				</td>
			</tr>
		</table>
	</div>
</div>

<div class="pageContent" style="border-left:1px #B8D0D6 solid;border-right:1px #B8D0D6 solid">
	<table class="table" layoutH="87">
		<thead>
			<tr>
                <th width="25px">
                <input type="checkbox" group="ids" class="checkboxCtrl" onchange="submitAllUserRightChange($(this).attr('checked'));" /></th>
				<th width="100px">编码</th>
				<th width="120px">名称</th>
			</tr>
		</thead>
		<tbody tag='rightassign'>
            <asp:repeater runat="server" id="rights">
                <ItemTemplate>
			    <tr rel='<%# ((IDictionary)Container.DataItem)["RightCode"]%>'>
                    <td><input name="ids" onchange="submitUserRightChange('<%# ((IDictionary)Container.DataItem)["RightCode"]%>',$(this).attr('checked'));" value="<%# ((IDictionary)Container.DataItem)["RightCode"]%>" type="checkbox" <%#((IDictionary)Container.DataItem)["RightValue"]!=null?"checked='checked'":""%> /></td>
				    <td><%# ((IDictionary)Container.DataItem)["RightCode"]%></td>
				    <td><%# ((IDictionary)Container.DataItem)["RightName"]%></td>
			    </tr>
                </ItemTemplate>
            </asp:repeater>
		</tbody>
	</table>

     <%= _framePage.GetPagerContentHtml()%>
</div>
	</div>
	
</div>
<script type="text/javascript">

    function changeUserRight(codes, val) {
        $.ajax({
            url: '/SystemManage/Basics/RightConfig/UserRight/UserRightAssign.aspx',
            data: { ajax: 1, group: '<%=group.SelectedValue %>', codes: $.toJSON(codes), val: (val ? "1" : "0"), user: '<%=CurrentUser %>', temp: new Date().valueOf() },
            type: 'POST',
            dataType: 'json',
            cache: false,
            error: function(data) {
            },
            success: function(result) {
            }
        });
    }

    function submitUserRightChange(code, val) {
        var codes = [];
        codes.push(code);
        changeUserRight(codes, val);
    }

    function submitAllUserRightChange(val) {
        var codes = [];
        $('tbody[tag=rightassign]>tr[rel]').each(function() {
            codes.push($(this).attr('rel'));
        });
        changeUserRight(codes, val);
    }
</script>

</form>
